<?php 
function subwords($words,$num){

	$total_num = str_word_count($words); 

	if($total_num <= $num){  
		return $words;
	}else{
		$pattern = '/([\S]+?[ ]+){'.$num.'}/';
		preg_match($pattern, $words, $out);
		if(isset($out[0])){
			return $out[0].'...';
		}else{
			return substr($words,0,$num*3).'...';
		} 
	}
}

?>
<?php $posts = $this->getPosts(); ?>
<h2>Testimonials...</h2>
<div class="newslist">
	<?php foreach ($posts as $post): ?>
	<div class="newslistItem">
	    <h3><a href="<?php echo $post->getAddress(); ?>"><?php echo $post->getTitle();?></a></h3>
	    <div class="intro"><?php echo subwords(strip_tags($post->getPostContent()),30); ?></div>
	    <a href="<?php echo $post->getAddress(); ?>" class="readmore">READ MORE &gt;&gt;&gt;</a>
	</div>
	<?php endforeach; ?>
</div>
<?php $this->getPages(); ?>
